package com.agile.leetcode.order.redis;

import java.util.concurrent.CountDownLatch;

/**
 * 高并发情况下的演示
 *
 * @Author:ChenZhangKun
 * @Date: 2023/1/4 21:09
 */
public class MultiThread {
    private static final int THREAD_NUM = 10;

    static CountDownLatch latch = new CountDownLatch(THREAD_NUM);

    static class DelayMessage implements Runnable {
        @Override
        public void run() {
            try {
                latch.await();
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            RedisOrder redisOrder = new RedisOrder();
            redisOrder.consumerDelayMessage();
        }
    }

    public static void main(String[] args) {
        RedisOrder redisOrder = new RedisOrder();
        redisOrder.productionDelayMessage();
        for (int i = 0; i < THREAD_NUM; i++) {
            new Thread(new DelayMessage()).start();
            latch.countDown();
        }

    }

}
